using System;

namespace Be.Timvw.Framework
{
    public static class EnumHelper
    {
        public static T Parse<T>(string value)
        {
            return (T) Enum.Parse(typeof(T), value, true);
        }

        public static bool TryParse<T>(string value, out T result)
        {
            try
            {
                result = Parse<T>(value);
                return true;
            }
            catch
            {
                result = default(T);
                return false;
            }
        }

        public static T Convert<T>(Enum value)
        {
            return Parse<T>(value.ToString());
        }
    }
}